package com.shop.service;

import com.shop.model.Course;
import com.shop.model.Student;

import java.util.ArrayList;
import java.util.List;

public class BuyService implements IBuyService {
    IStudentService istudentService = new StudentService();
    public double buy_tprice(List<Course> courses,String studentId){
        Student student = istudentService.search(studentId);
        String identity = student.getIdentity();
        double total_price = 0;
        for (Course course : courses) {
            total_price += course.getPrice();
        }
        if (identity.equals("学生VIP")){
            total_price =total_price * 0.6;
        } else if (identity.equals("学生")) {
            total_price=total_price * 0.97;
        }
        return total_price;
    }
    public List<Double> buy_price(List<Course> courses,String studentId){
        Student student = istudentService.search(studentId);
        String identity = student.getIdentity();
        List<Double> prices = new ArrayList<>();
        if( identity.equals("学生VIP")){
            for(Course course : courses){
                prices.add(course.getPrice() * 0.6);
            }
        }else if (identity.equals("学生")){
            for (Course course : courses) {
                prices.add(course.getPrice() * 0.97);
            }
        }
       return prices;
    }

}
